<?php

  class ShangchuanAction extends CommonAction{
  
     public function add(){
	 

	   layout(false);
	   
	   
	   $this->display();
	 
	 }
	 
	 
	 
	 public function addnow(){
	 
	 
	    $user=M('dailiuser')->where('id="%s"',session('did'))->find();
		
		
		
		
	 
	    if(!empty($_FILES)){
	  
	    $info=$this->upload('./images/');
		
		if($info){
		
		  $size=$info[0]['size']/1024;
		  $size= round($size,2);
		  
		  if($size>1024){
		  
		    $s=$size/1024;
			
			$s=round($s,2);  
		  
		    $s=$s."M";
		  
		  }else{
		  
		  
		    $s=$size."kb";
		  
		  }
		  
		
		  $_POST['size']=$s;
		
		
		
		   $_POST['video']=$info['0']['savename'];
		  
		  
		   $savename  =  strstr ( $info['0']['savename'] ,  '.' ,  true );  
		   
		   $mp4  ='./images/'.date(Ymd)."/".$info['0']['savename'];
		   
		   $img=$savename.".jpg";
		      
			  //截图并获取视频时长
		   include "./made.php";
		
		}
		
		//$_POST['img']='/images/'.date(Ymd)."/".$img;
		
		
		$_POST['vtime']=$videoinfo['duration'];
		
		$_POST['time']=time();
		
		//$_POST['uid']=session('sid');
		
		$_POST['dailiid']=session('did');
		
	   /* $opts = array( 
		'http'=>array( 
		'timeout'=>6000000
		) 
       ); 
        $context = stream_context_create($opts);

        $issuccess = file_get_contents("http://hezeqiye.cn/qiniu/examples/upload.php?video=".$info[0]['savename'],false,$context);
		//dump($issuccess);die;
		if($issuccess==2){
		unlink('./images/'.$info['0']['savename']);
	    
		
		}*/
		$_POST['video']='/images/'.$info['0']['savename'];
		
		$re=M('pianku')->add($_POST);
		
		if($re){
		  $ajax=1;
		}else{
		  $ajax=2;
		}
		$this->ajaxReturn($ajax);
	  
	  }
	  
	 
	 
	 
	 }
	 
	 
	  
   
  
  
  }